package com.tryaging.privader;

import com.tryaging.anno.ReTry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import java.util.concurrent.TimeUnit;

/**
 * @author CKC
 * @DateTime 2021/11/21 12:54
 */
@Repository
public class Hello {
    @Value("${server.port}")
    private String port;

    private static int count = 1;

    @ReTry(value = 5, timeout = 6000)
    public String outMsg(String string) throws InterruptedException {
        TimeUnit.MILLISECONDS.sleep(1000);
        boolean flag = false;
        if (count == 4) {
            flag = true;
            count = 0;
        } else {
            count++;
            flag = false;
        }
        return flag ? Hello.class.getSimpleName() + "\t" + "port:" + port + "\t Msg:" + string : null;
    }
}
